package converter;

import fun.ltool.core.excel.convert.ExcelTypeConverter;

import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;

/**
 * 示例 自定义数据类型转换器
 */
public class LocalDateTimeExcelTypeConverter implements ExcelTypeConverter<LocalDateTime> {
    @Override
    public LocalDateTime convert(Object value, Class<?> fieldType) {
        if (value == null) {
            return null;
        }
        if (fieldType == LocalDateTime.class) {
            return LocalDateTime.parse(value.toString(), DateTimeFormatter.ofPattern("yyyy/M/dd HH:ss:mm"));
        }
        return null;
    }
}
